home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 263_02 / writfile.c < prev    next >
C/C++ Source or Header  |  1990-02-13  |  879b  |  33 lines

  1. #include <stdio.h>
  2. #include <c_wndw.h>
  3.  
  4. /*
  5. *    Copyright 1989, Marietta Systems, Inc.
  6. *    All rights reserved
  7. */
  8.  
  9. /*
  10. *   This sample program creates a binary file with 61 byte size records.
  11. *    The operator is then prompted for entry of a 60 byte string to enter
  12. *    into the file.
  13. */
  14.  
  15. void main()
  16. {
  17.      long recno = 1L;
  18.      int fh, ret = 1, x = 1;
  19.      clr_scrn ("Create a file");
  20.      fh = fileopen ("MARIETTA\\TEST.DAT", binary, recreate);
  21.      if (fh <= 0) goodbye (10); /* error end to the program */
  22.      fileinit (fh, 0, 61, 0L); /* record length at 61 bytes */
  23.      for (;;)
  24.      {
  25.           display ("Enter record: ", x++, 1, high);
  26.           ret = accept (FN[fh].record, left, alt_high, 60, 0);
  27.           if (ret == QUIT || ret == ESC) break;
  28.           if (filewrit (fh, &recno)) break; /* write out the record */
  29.      }
  30.      fileclos (fh);
  31.      goodbye (0);
  32. }
  33.